When a compiler compiles a program, a value defined in the program that in size is smaller than the size of a CPU register is converted to the size corresponding to that of the register.
For example, for a 64-bit architecture (a 64-bit specification for the use of 64 bits for operations and data transfers and for 64-bit memory addressing), a register image is 64 bits. Therefore, 32 bit, 16 bit and 8 bit values in a program must be handled as 64 bits by using sign extension. Sign extension is a process whereby the value of a code bit, the most significant bit of a defined value is extended into bits added to the defined value in order to obtain a value having a greater bit length.
In a sample program shown in FIG. 18, the function “extend ( )” is used for a sign extension of from 32 bits to 64 bits, and the “i” denotes a 32-bit variable in the program. In this example, assuming that “mem” represents the value 0xffffffff (“−1” for 32 bits with a sign) in a 32-bit memory, an error would occur in an array access (line (2)) if a sign extension instruction (line (1)) is not executed. Therefore, sign extension must be used so that the number of bits employed for a value match the CPU register image.
When a code written in a certain language that mainly employs 32-bit values for operations is to be compiled for use in a 64-bit architecture, not only loading from memory but also sign extension is required for almost all integer instructions. However, when the sign extension instruction is inserted as is shown in line (1) in FIG. 18, the execution speed of the program is accordingly reduced.
Sign extension is also required for a 32-bit architecture (i.e., a 32 bits register size) when 16-bit or 8-bit values are to be processed. On the other hand, for IA-32, which is a 32-bit architecture CPU, processor instructions (MOVSX, MOVZX) are provided for loading an instruction from memory and performing sign extension at the same time. Therefore, when these instructions are employed, the load sign extension imposes on the CPU need not be taken into account.
However, at the present, instructions for loading instructions from memory and performing sign extension at the same time are not generally known for 64-bit architectures. In addition, in the present situation wherein most systems and applications are designed based on the premise that 32-bit architecture will be used, sign extension instructions are actually necessary for many integer instructions, and program execution speeds are reduced.